Fix domain exit actions that contain hyphen
authorKeir Fraser <keir.fraser@citrix.com>
Wed, 3 Mar 2010 17:40:22 +0000 (17:40 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Wed, 3 Mar 2010 17:40:22 +0000 (17:40 +0000)
Domain exit actions that contain a hyphen (e.g. rename-restart) were
not being detected properly when xm is configured to use xenapi.
Domain config containing on_crash=3D"rename-restart" results in

xen53:~ # xm new /tmp/domU.config
Using config file "/tmp/domU.config".
Unexpected error: <type 'exceptions.TypeError'>

This patch fixes the raised exception and at the same time
handles the replacement of hyphen with underscore properly.

Signed-off-by: Jim Fehlig <jfehlig@novell.com>
tools/python/xen/xm/xenapi_create.py

index e56be763930bcb803674d47db2ec19b8d251d4f9..f53a1770fd79efa8fe6335a91ea7acc3197a6693 100644 (file)
@@ -664,11 +664,11 @@ class sxp2xml:
             = get_child_by_name(config, "on_crash", "restart")
 
         def conv_chk(val, vals):
-            val.replace("-", "_")
-            if val not in vals:
-                raise "Invalid value: " + val
+            lval = val.replace("-", "_")
+            if lval not in vals:
+                raise ValueError("Invalid value: %s" % val)
             else:
-                return val
+                return lval
 
         actions_after_shutdown = conv_chk(actions_after_shutdown,\
                                           XEN_API_ON_NORMAL_EXIT)